using System;
using System.Collections.Generic;
using System.Text;

namespace BookBarter
{
    public abstract class BookInst
    {
        //class variables
        private Condition condition;
        private Person person;
        private Book book;

        //class properties
        public Book Book
        {
            get
            {
                return book;
            }
            protected set
            {
                book = value;
            }
        }
        public Person Person
        {
            get
            {
                return person;
            }
            protected set
            {
                person = value;
            }
        }
        public Condition Condition
        {
            get
            {
                return condition;
            }
            set
            {
                condition = value;
                Save();
            }
        }

        //constructor
        protected BookInst(Condition cond, Person owner, Book book)
        {
            this.Condition = cond;
            this.Person = owner;
            this.Book = book;
        }

        /// <summary>
        /// Finds the condition of the book
        /// </summary>
        /// <param name="condition"></param>
        /// <returns>Returns the books condition</returns>
        protected static Condition LookupCondition(string condition)
        {
            return (Condition)Enum.Parse(typeof(Condition), condition, true);
        }

        /// <summary>
        /// saves the book instance
        /// </summary>
        protected void Save()
        {
            //only used for subclasses
        }
    }

}
